<template>
  <div class="page-content">
    <div class="header">
      <h3>图文课程管理</h3>
    </div>

    <el-tabs v-model="activeName">
      <el-tab-pane label="课程管理" :name="1"></el-tab-pane>
    </el-tabs>

    <div class="question-group">
      <div class="left">
        <AddImageDialog ref="groupComponent" :file-type="0" @select-group="handleSelectedGroup"
          @get-groupId="getgroupId"></AddImageDialog>
      </div>
      <div class="right">
        <div class="header">
          <h3>图文列表</h3>
          <p v-if="carModelInfo">（{{ carModelInfo }}）</p>
        </div>
        <image-text-list-table :key="videoTableKey" :edit-info="editData" :group-id="groupId"
          @uploadGroup="uploadGroup"></image-text-list-table>
      </div>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { onMounted, ref } from 'vue'
import imageTextListTable from '@/views/question_bank/components/imageTextListTable.vue'
import AddImageDialog from './components/AddImageDialog.vue'

interface User {
  id: number | string
  name: string
  img: string
  parentId?: string | number
  questionCount?: number
  children?: User[]
}

const groupComponent = ref()

const activeName = ref(1)
const editData = ref<any>()

const videoTableKey = ref(1)
const carModelInfo = ref('')
const groupId = ref('')

function handleSelectedGroup(value: any) {
  editData.value = value
  groupId.value = value.id
  videoTableKey.value = new Date().getTime()
}

function getgroupId(value: any) {
  groupId.value = value
  videoTableKey.value = new Date().getTime()
}

function uploadGroup() {
  groupComponent.value.getData()
}

onMounted(async () => {
  // await getData()
  // groupComponent.value.getDefaultGroupId()
})
</script>

<style lang="scss" scoped>
::v-deep(.row-parent) {
  background-color: #f4f6f8;
}

::v-deep(.row-child) {
  background-color: #fff;
}

.drag-over-line {
  position: absolute;
  height: 2px;
  background-color: #409eff;
  left: 0;
  right: 0;
  top: 0;
  z-index: 10;
}

.icon-drag {
  color: var(--el-color-primary);
  margin-right: 10px;
  cursor: move;
}

.icon-rotate {
  color: var(--el-color-primary);
  display: inline-block;
}

.icon {
  margin-right: 10px;
  margin-bottom: -6px;
}

.child-drag {
  padding-left: 45px;
}

.page-content {
  .header {
    margin-bottom: 20px;
  }
}

.question-group {
  display: flex;
  width: 100%;

  .left {
    width: 300px;
    margin-right: 20px;

    .header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 20px;
    }
  }

  .right {
    flex: 1;
    height: 100%;
    overflow-x: auto;

    .header {
      display: flex;
      align-items: center;
      margin-bottom: 20px;

      p {
        margin-left: 2px;
        font-size: 12px;
      }
    }
  }
}
</style>